#include "StdAfx.h"
#include "FileFilterCreator.h"

//------------------------------------------------------------------------

void FileFilterCreator::AddFilter(const Filter & m_filter, const Description & m_description)
  {
  m_filters[m_filter] = m_description;
  }

//------------------------------------------------------------------------

void FileFilterCreator::AddFilter(const wchar_t * m_filter, const wchar_t * m_description)
  {
  std::wstring filter = m_filter;
  std::wstring description = m_description;
  AddFilter(filter, description);
  }

//------------------------------------------------------------------------

void FileFilterCreator::RemoveFilter(const Filter & m_filter)
  {
  m_filters.erase(m_filter);
  }

//------------------------------------------------------------------------

void FileFilterCreator::AddForAllFilter(bool i_add)
  {
  m_add_forall_filter = i_add;
  }

//------------------------------------------------------------------------

void FileFilterCreator::Create()
  {
  for (std::map<Filter, Description>::const_iterator filter_cit = m_filters.begin(); filter_cit != m_filters.end(); ++filter_cit)
    {
    m_filter_string += filter_cit->second;
    m_filter_string += L" (";
    m_filter_string += filter_cit->first;
    m_filter_string += L")|";
    m_filter_string += filter_cit->first;
    m_filter_string += L"|";
    }
  if (m_add_forall_filter)
    m_filter_string += L"All Files (*.*)|*.*|";
  }

//------------------------------------------------------------------------

std::wstring FileFilterCreator::GetFilterString() const
  {
  return m_filter_string;
  }

//------------------------------------------------------------------------